package bst;

import java.util.ArrayList;
import java.util.Random;

public class TestMinMax {

    public static void main(String[] args) {
        BST<Integer> bst = new BST<>();
        Random random = new Random();
        int n = 1000;

        // test removeMin
        for (int i = 0; i < n; i++)
            bst.add(random.nextInt(Integer.MAX_VALUE));

        ArrayList<Integer> nums = new ArrayList<>();
        while (!bst.isEmpty())
            nums.add(bst.removeMin());

        for (int i = 1; i < nums.size(); i++)
            if (nums.get(i -1) > nums.get(i))
                throw new IllegalArgumentException("Error!");
        System.out.println("removeMin test completed.");

        // test removeMax

        for (int i = 0; i < n; i++)
            bst.add(random.nextInt(Integer.MAX_VALUE));
        nums = new ArrayList<>();
        while (!bst.isEmpty())
            nums.add(bst.removeMax());

        for (int i = 1; i < nums.size(); i++)
            if (nums.get(i-1) < nums.get(i))
                throw new IllegalArgumentException("Error!");
        System.out.println("removeMax test completed.");
    }
}
